<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>搜索企业</title>
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>

    <link rel="stylesheet" href="../js/libs/sui/sm.min.css">
    <link rel="stylesheet" href="../js/libs/sui/sm-extend.min.css">
    <link rel="stylesheet" href="../iconfont/iconfont.css">
    <link rel="stylesheet" href="../less/main.css"/>

    <script type="text/javascript" src='../js/libs/jquery-3.1.0.min.js' charset='utf-8'></script>
    <script type="text/javascript">
        var Zepto = jQuery;
    </script>
    <script type="text/javascript" src='../js/libs/sui/sm.js' charset='utf-8'></script>
    <script type="text/javascript" src='../js/libs/sui/sm-extend.min.js' charset='utf-8'></script>
    <script type="text/javascript" src="../js/libs/juicer-min.js"></script>
    <script type="text/javascript" src="../js/libs/jquery.md5.js"></script>
    <script type="text/javascript" src="../js/api.js"></script>
    <script type="text/javascript" src="../js/utils.js"></script>
    <script type="text/javascript" src="../js/common.js"></script>
</head>
<body>
<div class="content job-search bg-default">
    <!--搜索栏-->
    <div class="row no-gutter search-head bg-theme">
        <div class="col-10">
            <i class="icon iconfont c-white p-l" onclick="javascript:closeWin();">&#xe61f;</i>
        </div>
        <div class="col-90 right">
            <div class="searchbar row no-gutter">
                <div class="search-input col-85">
                    <label class="icon iconfont" for="cy-search-company-input">&#xe60e;</label>
                    <input type="search" id='cy-search-company-input' placeholder='输入公司或职位……'/>
                </div>
                <a id="cy-search-company-btn" class="button button-fill bg-theme t-right col-15">搜索</a>
            </div>
        </div>
    </div>
    <!--搜索内容-->
    <div id="cy-search-company-list" class="list-block media-list list-job">
        <p class="t-center w-100p f-time c-gray">搜索结果 ...</p>
        <!--
        <ul>
            <li>
                <a load="public/pag../company-info.html" title="最新资讯" progress="false">
                    <div class="item-content">
                        <div class="item-media item-pb-0"><img src="http://gqianniu.alicdn.com/bao/upload..//tfsc../TB10LfcHFXXXXXKXpXXXXXXXXXX_!!0-item_pic.jpg_250x250q60.jpg" style='width: 3rem;'></div>
                        <div class="item-inner item-pb-0">
                            <div class="item-title-row">
                                <div class="item-title c-default">贵州安云科技有限公司</div>
                            </div>
                            <div class="item-subtitle">以软件、产品开发为主导，集产品研发研发</div>
                        </div>
                    </div>
                    <div class="item-foot">查看详细 <span class="icon icon-right"></span></div>
                </a>
            </li>
        </ul>
        -->
    </div>
</div>

<!-- 企业介绍模版 -->
<script id="cy-search-company-list-tpl" type="text/template">
    {@each companyList as it, index}
    <ul>
        <li>
            <a class="cy-company" data-unit-id="&{it.UNIT_ID}" progress="false" href="javascript:void(0);">
                <div class="item-content">
                    <div class="item-media item-pb-0"><img src="&{url}&{it.PIC_PATH}" style='width: 3rem;'></div>
                    <div class="item-inner item-pb-0">
                        <div class="item-title-row">
                            <div class="item-title c-default">&{it.UNIT_NAME}</div>
                        </div>
                        <div class="item-subtitle">$${it.REMARKS}</div>
                    </div>
                </div>
                <div class="item-foot">查看详细 <span class="icon iconfont">&#xe620;</span></div>
            </a>
        </li>
    </ul>
    {@/each}
</script>

<script type="text/javascript">
    apiready = function() {
        juicer.set({
            'tag::operationOpen': '{@',
            'tag::operationClose': '}',
            'tag::interpolateOpen': '&{',
            'tag::interpolateClose': '}',
            'tag::noneencodeOpen': '$${',
            'tag::noneencodeClose': '}',
            'tag::commentOpen': '{#',
            'tag::commentClose': '}',
            'strip': false,
            'cache': false
        });

        // 按公司名称或岗位名称搜索公司
        var sql = "SELECT DISTINCT T1.* FROM E_COOPERATION_UNIT T1, E_RECRUIT_POST T2 WHERE T1.UNIT_ID = T2.UNIT_ID AND (T1.UNIT_NAME LIKE '%{0}%' OR T2.POST_NAME LIKE '%{1}%')";

        $("#cy-search-company-btn").click(function () {
            var $input = $("#cy-search-company-input");
            // 搜索关键字
            var keyword = $input.val();

            if (isEmpty(keyword)) {
                api.toast({
                    msg: "请输入公司或职位"
                });

                $input.focus();
            } else {
                var tmpSql = sql.format(keyword, keyword);

                dbQuery(1, 10, tmpSql, true, function (ret, err) {
                    // 执行成功
                    if (isObject(ret) && (ret.statusCode == 0)) {
                        var companyData = {
                            url: getUrl(),
                            companyList: ret.result
                        };

                        if (companyData.companyList.length <= 0) {
                            toast("搜索不到公司");

                            $("#cy-search-company-list").empty();
                        } else {
                            $("#cy-search-company-list").html(juicer($("#cy-search-company-list-tpl").html(), companyData));
                        }
                    }
                });
            }
        });

        $("#cy-search-company-list").on("click", ".cy-company", function () {
            var $this = $(this);
            var unitId = $this.data("unitId");

            openWin("company-info", "company-info.html", {
                unitId: unitId
            });
        });
    };
</script>
</body>
</html>